 nn4 = (document.layers)? true : false;
 ie4 = (document.all)? true : false;

 function putElem(elemId)
 { if (ie4) document.all[elemId].style.display = "block";
   else document.getElementById(elemId).style.display = "block";
 }
 function removeElem(elemId)
 { if (ie4) document.all[elemId].style.display = "none";
   else document.getElementById(elemId).style.display = "none";
 }
 function Editor()
 { if (ie4) document.all['layer2'].style.display = "none";
   else document.getElementById('layer2').style.display = "none";
   if (ie4) document.all['layer1'].style.display = "block";
   else document.getElementById('layer1').style.display = "block";
   iView.document.body.innerHTML = document.f1.data_new.value;
   EditMode=1;
 }
 function Init()
 { iView.document.designMode = 'On';
   if (ie4) document.all['layer2'].style.display = "none";
   else document.getElementById('layer2').style.display = "none";
   if (ie4) document.all['layer1'].style.display = "block";
   else document.getElementById('layer1').style.display = "block";
     EditMode=1;
 }
 function Html()
 { if (ie4) document.all['layer1'].style.display = "none";
   else document.getElementById('layer1').style.display = "none";
   if (ie4) document.all['layer2'].style.display = "block";
   else document.getElementById('layer2').style.display = "block";
   document.f1.data_new.value = iView.document.body.innerHTML;
   EditMode=0;
 }
 function bold()
 { iView.document.execCommand('bold', false, null);
 }
 
  function table()
 { 
 
 document.getElementById('tab').style.display = "block";
 }
 
  function parser()
 { 
 
 Html();
 while (document.f1.data_new.value.indexOf('style=',0)!=-1) {

 document.f1.data_dubl.value=document.f1.data_new.value.indexOf('style=',0); 
 var t= document.f1.data_dubl.value;

  t_vr= parseInt(t)+7;
 
 document.f1.data_dubl.value=document.f1.data_new.value.indexOf('"',t_vr);  
 var t_n= document.f1.data_dubl.value;
 
  t_beg= parseInt(t)-1;
  t_end= parseInt(t_n)+1;
 
  document.f1.data_dubl.value=document.f1.data_new.value.substring(t_beg,t_end);
 var t_str= document.f1.data_dubl.value; 
 
 document.f1.data_new.value= document.f1.data_new.value.replace(t_str,'');
 }
 document.f1.data_new.value=document.f1.data_new.value.replace('<TABLE','<TABLE class="table_1"'); 
 Editor();
  }
 
 function Italic()
 { iView.document.execCommand('italic', false, null);
 }
 function Underline()
 { iView.document.execCommand('Underline', false, null);
 }
 function Left()
 { iView.document.execCommand('JustifyLeft', false, null);
 }
 function Center()
 { iView.document.execCommand('JustifyCenter', false, null);
 }
 function Justify()
 { iView.document.execCommand('JustifyFull', false, null);
 }
 function Right()
 { iView.document.execCommand('JustifyRight', false, null);
 }
 function List()
 { iView.document.execCommand('InsertUnorderedList', false, null);
 }
 function FontColor(color)
 { iView.document.execCommand('forecolor', false, color); 
   HideFont();
 }
 function FontName(font)
 { iView.document.execCommand('FontName', false, font); 
 } 
 function FontSize(size)
 { iView.document.execCommand('FontSize', false, size); 
 } 
 function Font()
 { var x = document.body.scrollLeft + event.x - 20;
   var y = document.body.scrollTop + event.y + 20;
   if (ie4) { document.all['color'].style.visibility = "visible";
   document.all['color'].style.left =x; document.all['color'].style.top =y;
            } else { 
   document.getElementById('color').style.visibility = "show";
   document.layers['color'].left =x; document.layers['color'].Top =y;
 }                 } 
 function HideFont()
 { if (ie4) document.all['color'].style.visibility = "hidden";
   else document.getElementById('color').style.visibility = "hidden";
 }                 
 function Save()  
 { document.f1.action.value='savechangesdata';
   if (EditMode==1) document.f1.data_new.value = iView.document.body.innerHTML;
 }
 function GetText()
 { iView.document.selection.createRange().text="{-}"+
   iView.document.selection.createRange().text;
   document.f1.seltext.value = iView.document.selection.createRange().text;   
   document.f1.data_new.value = iView.document.body.innerHTML;
 }
 
  function AddTbl() {
	
 
    var nTable = '<TABLE style=" width="'+document.f1.width.value+'" height="'+document.f1.height.value+'" cellpadding="'+document.f1.padding.value+'" cellspacing="'+document.f1.spacing.value+'" border="'+document.f1.border.value+'">'; //+' bgcolor=#'+document.forms['tblf'].elements['bgcolor'].value+'>';
	for (r=0;r<document.f1.rows.value;r++) {
		nTable += '<tr>';
		for (c=0;c<document.f1.cols.value;c++) {
			nTable += '<td valign="top"></td>';
		}
		nTable += '</tr>';
	}
	nTable += '</TABLE>';
 
  iView.document.body.innerHTML=iView.document.body.innerHTML+nTable;
  document.getElementById('tab').style.display = "none";

}

